var TowerA = Tower.extend({
    ///////////////////////////////////////////////////////////
    ctor : function( filename,towerData ){//series,power,speed,fireRange,fireTime,bulletRes
        this._super(filename,towerData);
    },
    onEnter:function () {
        this._super();
    },
    onExit : function(){
        this._super();
    },
    newBullet : function(direct,distance){
        cc.log("new bullet");
        var name = "res/"+this._bulletRes;
        var newBullet = BulletA.create( name,this._power,this._speed );
        newBullet.setPosition(this.getPosition());
        newBullet.setSpeedScale(direct,distance);
        // set bullet size
        var mainLayer = getMainLayerInstance();
        mainLayer.addChild(newBullet,10 );
        this._bullets.push(newBullet);
    },
    reviveBullet : function(bullet,direct,distance){
        bullet.setPosition(this.getPosition());
        bullet.setSpeedScale(direct,distance);
        // set bullet size
        bullet.setVisible(true);
    },
    fighting : function(direct){
        if (this._canFire){
            var that=this;
            var distance = cc.pDistance(this._position,direct );
            if ( distance<this._fireRange ){
                cc.log("distance: "+distance);
                this._canFire = false;
                var bullet = this.getBulletFromBuffer();
                if ( bullet ){
                    this.reviveBullet(bullet,direct,distance);
                }else{
                    this.newBullet(direct,distance);
                }
                this.runAction( cc.Sequence.create(
                    new cc.DelayTime( this._fireTime ),
                    new cc.CallFunc( function(){ that._canFire = true;cc.log("open fire trigger");} )
                ));
            }
        }
    }
});
////////////////////////////////////////////////////////////////
TowerA.create = function (filename,towerData ) {
    var tower = new TowerA(filename,towerData );
    return tower;
};
